<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="myTags" tagdir="/WEB-INF/tags/components" %>
<%@ page import="data.ContentTypeDB, beans.Group" %>
<% Group group = new Group(); %>

<!-- Author: Minh-Tuan Ta -->

<div id="profileDiv">

	<div id="profilePanel">
		<div id="profileUserDetails">
			<h3>${user.firstName } ${user.lastName }</h3>
			<span id="profdivide"><img src="images/profile-divide.png"/></span>
			<img id="profilePicture" src="${user.picturePath }" /><br />
			<span id="updatelink"><a href="UpdateProfile?userID=${user.userID }">UpdateProfile</a></span><br />
			<h4><img src="images/icons/birthdayicon.png"/> Birthday: ${user.dob}</h4>
			<h4><img src="images/icons/messageicon.png"/> Email:    ${user.email}</h4>
			<br />
		</div>
		
		<div id="profileControlPanel">
			<ul id="profileControls">
				<c:if test="${user.userID == User.userID }">
					<li><a href="Messages">Messages (<span class="<c:if test="${numOfUnreadMessages > 0 }">hasNew</c:if>">${numOfUnreadMessages }</span>)</a></li>
					<li><a href="Friends">Friend Requests: <span class="<c:if test="${numOfFriendRequests > 0 }">hasNew</c:if>">${numOfFriendRequests }</span></a></li>
				</c:if>
				
				<c:if test="${isFriend == true && user.userID != User.userID }">
					<li><a href="Albums?userID=${user.userID }">Photos</a></li>
				</c:if>
				<c:if test="${isFriendRequestSent == false && user.userID != User.userID }">
					<form action="AddFriend" method="post">
						<input type="hidden" name="userID" value="${user.userID }" />
						<input type="submit" name="submit" value="Add Friend" />
					</form>
				</c:if>
				<c:if test="${isFriendRequestSent == true && isFriend == false }">
					Friend Request has been sent
				</c:if>
			</ul>
		</div>
		<div id="profileFriends">
			<h3>Friends</h3>
			<c:forEach var="friend" items="${friends}">
			<div class="friendSurround">
				<myTags:SmallUserBlock user="${friend}"></myTags:SmallUserBlock>
				<myTags:MessageLink user="${friend}"></myTags:MessageLink>
			</div>
			</c:forEach>
		
		</div>
		<%-- 
			 Author   : Corey Stone
			 		  : Keith Westphal
			 abstract : Add groups function to profile page 
		 --%>
		<div id="Groups">
			<h3>Groups</h3>
			<a href="CreateGroup"> add group </a><br />
			<c:forEach var="group" items="${groups}">
				<a href="Groups?groupid=${group.group_id }">${group.group_name }</a><br />
			</c:forEach>
		</div>
	</div>
	
	
	<div id="profileContent">
		<c:if test="${user.userID == User.userID }"><a href="CreatePost"><span class="linkButton">Create A New Post</span></a></c:if>
		<c:if test="${user.userID == User.userID || isFriend == true }">
			<c:forEach var="post" items="${requestScope.posts }">
				<myTags:Post post="${post}"></myTags:Post>
			</c:forEach>
		</c:if>
	</div>
</div>